import { snakeToCamel } from 'csui'

/**
 * 组装成全局注册组件的数据结构
 * @returns 组件数组
 */
const transComponent = () => {
  const svgFiles: any = import.meta.glob('./icons/*.svg', {
    eager: true
  })

  const iconComponents = []
  for (const fileName in svgFiles) {
    const component = svgFiles[fileName].default
    // 为组件添加组件名
    component.name = `SvgIcon${snakeToCamel(
      fileName.replace('./icons/', '').replace('.svg', '')
    )}`
    iconComponents.push(component)
  }
  return iconComponents
}

export default transComponent()
